﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.SheepRescissionCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.SheepRescissionCommandHandler
{
    /// <summary>
    /// 羊只转舍获取在场耳号
    /// </summary>
    public class SheepRescissionEarTagCommandHandler : IRequestHandler<SheepRescissionEarTagCommand, Results<List<Eartag>>>
    {
        private readonly ISheepRescissionService _sheepRescissionService;

        public SheepRescissionEarTagCommandHandler(ISheepRescissionService sheepRescissionService)
        {
            _sheepRescissionService = sheepRescissionService;
        }
        public async Task<Results<List<Eartag>>> Handle(SheepRescissionEarTagCommand request, CancellationToken cancellationToken)
        {
            var result = await _sheepRescissionService.GetEweEarTagsFromSheepFile();
            return Results<List<Eartag>>.DataResult(result);
        }
    }
}
